global
    log         127.0.0.1 local2 

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        root
    group       root
    daemon

    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats level admin

defaults
    mode                    {{ mode }}
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

backend app
    {% for host in groups.tag_ansible_group_lbservers %}
    	listen {{ daemonname }} 0.0.0.0:{{ listenport }}
    {% endfor %}
    balance     {{ balance }}
    {% for host in groups.tag_ansible_group_webservers %}
        server {{ host }} {{ hostvars[host]['ansible_' + iface].ipv4.address }}:{{ httpd_port }}
    {% endfor %}
